package com.itheima.tliasmanagent.controller;

import com.itheima.tliasmanagent.pojo.Emp;
import com.itheima.tliasmanagent.pojo.LoginInfo;
import com.itheima.tliasmanagent.pojo.Result;
import com.itheima.tliasmanagent.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class LoginController {

    @Autowired
    private EmpService empService;

    @PostMapping ("/login")
    public Result login(@RequestBody Emp emp){
        log.info("用户登录{}",emp);
      LoginInfo loginInfo= empService.login(emp);
//        LoginInfo loginInfo = new LoginInfo();
        if(loginInfo !=null){
            // 登录成功
            return Result.success(loginInfo);
        }
        return Result.error("用户名或者密码输入错误");
    }


}
